package com.bj58.groupbuy.action.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.bj58.groupbuy.action.db.DBConfig;
import com.bj58.groupbuy.action.db.UserPriviledgeDao;
import com.bj58.groupbuy.action.model.Role;
import com.bj58.groupbuy.action.model.RolePriviledge;
import com.bj58.groupbuy.action.service.RolePriviledgeService;

public class RolePriviledgeServiceImpl implements RolePriviledgeService {
	private static UserPriviledgeDao comDao = new UserPriviledgeDao();
	
	@Override
	public List<RolePriviledge> getPriviledgeByRoleid(long roleid) throws Exception {
		String sql = "select * from role_priviledge where roleid = " + roleid;
		return comDao.getAllColsByVo(sql, RolePriviledge.class, DBConfig.db_68_bi_sys.getIntType());
	}

	@Override
	public boolean delPriviledgeByRoleid(long roleid) throws Exception {
		return comDao.deleteData("role_priviledge", " and roleid='"+roleid+"'", DBConfig.db_68_bi_sys.getIntType());
	}
	
	public boolean saveRoleFunctions(String functions,Role r,String opers) throws SQLException{
		return comDao.saveRoleByfunctions(functions, r, opers,DBConfig.db_68_bi_sys.getIntType());
	}

	@Override
	public boolean updateRoleFunctions(Role r, String functions ,String opers)throws Exception {
		return comDao.updateRoleFunction(r, functions, opers , DBConfig.db_68_bi_sys.getIntType());
	}
}
